//负责创建schema对象和model对象
const mongoose = require('mongoose')

// 创建约束对象(schema)
const schema = new mongoose.Schema({
  name: {
    type: String,
    required: true,
    unique: true,
  },
  psw: {
    type: String,
    required: true,
  },
  last_login: {
    type: Date,
    default: Date.now(),
  },
  registe_date: {
    type: Date,
    default: Date.now(),
  },
  //   这个token用于登录之后,存储登录的令牌
  token: {
    type: String,
  },
})

// 创建集合对象(model)
module.exports = mongoose.model('admins', schema)
